<?php
namespace BoxApi\Controller;

use Think\Controller;

class SnsController extends CommonController {

	//评论
	function comment() {
		$topic_id = I('topic_id', "0", "intval");
		$data = Logic("BoxSns", "Comment")->get(array('topic_id' => $topic_id, 'type' => I('type'), 'limit' => 30, 'orderBy' => 'id desc'));
		exit(json_encode($data));

	}

	//答疑列表
	function topic() {
		$where = array(
			'is_show' => 1,
			'type' => 'eduAsk',
		);
		$limit = I('limit', "10", "intval");
		//课程
		if ($pid = I('pid', "", "intval")) {
			$where['pid'] = $pid;
		}
		//章节
		if ($pid2 = I('pid2', "", "intval")) {
			$where['pid2'] = $pid2;
		}
		//课时
		if ($pid3 = I('pid3', "", "intval")) {
			$where['pid3'] = $pid3;
		}
		//题
		if ($pid4 = I('pid4', "", "intval")) {
			$where['pid4'] = $pid4;
		}
		$data = BoxModel("sns_topic")->get($where, $limit, "lastupdate desc");
		exit(json_encode($data));
	}

}